<?php

abstract class Core_ControllerAbstract extends Zend_Controller_Action{
	public $view = null;
	
	public $theme = 'default';
	
	public $_session = null;
	
	public function init(){
		parent::init();
		$this->view = new Zend_View_Smarty(
			PATH_APLICATION
			, PATH_TEMP . "html"
			, $this->_request->getModuleName()
		);
		$this->viewSuffix = "html";
		
		preg_match("#(.*?)index.php$#",$_SERVER["PHP_SELF"],$arr);
		$this->view->baseUrl = "http://{$_SERVER["HTTP_HOST"]}" . $arr[1];
		
		$this->_session = new Zend_Session_Namespace("default");
		self::setTheme();
	}
	
	public function setTheme($strTheme = null){
		if($strTheme !== null){
			$this->theme = $strTheme;
			$this->_session->theme = $strTheme;
		}else if($strTheme = $this->_request->getParam("theme")){
			$this->theme = $strTheme;
			$this->_session->theme = $strTheme;
		}else{
			$this->_session->theme = $this->theme;
		}
		
		$this->view->theme = $this->_session->theme;
	}
}